#include "../include/student.h"

Student::Student(){

}

Student::Student(const std::string &studentID, const std::string &name)
    : studentID(studentID), name(name)
{
}

// 设置学号
void Student::setStudentID(const std::string &studentID)
{
    this->studentID = studentID;
}

// 设置姓名
void Student::setName(const std::string &name)
{
    this->name = name;
}
// 屏幕输出
void Student::print()
{
    std::cout << "学号: " << studentID << ", 姓名: " << name << std::endl;
}
// 本地文件保存
void Student::save(const std::string &filename)
{
    // 打开一个输出文件流
    std::ofstream file(filename, std::ios::app);
    if (!file.is_open())
    {
        std::cout << "未找到文件！" << std::endl;
        return;
    }

    file << studentID << "," << name;

    // 关闭文件流
    file.close();
}